package www.yingdi365.com.viewholder;

import android.content.Intent;
import android.support.annotation.LayoutRes;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

import www.yingdi365.com.R;
import www.yingdi365.com.activity.WebActivity;
import www.yingdi365.com.activity.ZaZhiYLActivity;
import www.yingdi365.com.constant.Constant;
import www.yingdi365.com.model.AppMagazineTmpl;

/**
 * Created by Administrator on 2017/3/28 0028.
 */
public class ZaZhiViewHolder extends BaseViewHolder<AppMagazineTmpl> {
    private final ImageView imageThumb;
    private AppMagazineTmpl data;
    public ZaZhiViewHolder(ViewGroup parent, @LayoutRes int res) {
        super(parent, res);
        imageThumb = $(R.id.imageThumb);
        $(R.id.textZhiZuo).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(getContext(), ZaZhiYLActivity.class);
                intent.putExtra(Constant.INTENT_KEY.TmplsBean, data);
                getContext().startActivity(intent);
            }
        });
    }

    @Override
    public void setData(final AppMagazineTmpl data) {
        super.setData(data);
        this.data = data;
        Glide.with(getContext())
                .load(data.getThumb())
                .placeholder(R.mipmap.preview)
                .into(imageThumb);
        imageThumb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getContext(), WebActivity.class);
                intent.putExtra(Constant.INTENT_KEY.TITLE, data.getName());
                intent.putExtra(Constant.INTENT_KEY.URL, data.getPath());
                getContext().startActivity(intent);
            }
        });
    }

}
